from fastapi import APIRouter, Depends, Request
from sqlalchemy.ext.asyncio import AsyncSession

from config.get_db import get_db
from module_admin.entity.vo.user_info_vo import UserInfoResponse
from module_admin.service.user_info_service import UserInfoService
from utils.response_util import ResponseUtil
from module_admin.service.login_service import LoginService


userInfoController = APIRouter(prefix="/appUser")


@userInfoController.get("/info", summary="获取当前用户信息")
async def get_current_user_info(
    request: Request,
    current_user: dict = Depends(LoginService.get_current_user),
    query_db: AsyncSession = Depends(get_db)
):
    """
    获取当前登录用户的信息
    """
    result = await UserInfoService.get_user_info(query_db, current_user.user.user_id)
    return ResponseUtil.success(data=result, msg="获取用户信息成功")
